home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Resource Library: Multimedia
/
Resource Library: Multimedia.iso
/
hypercrd
/
xcmds
/
rtf-redr.hqx
/
RTFText.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-12-19
|
2KB
|
86 lines
/*
* This software is copyright 1992 by Robert Morris.
* You may freely redistribute this software as shareware
* if you do so in the same form as you got it. If you find
* this software useful, please send $12 to:
* Robert Morris
* P.O. Box 1044
* Harvard Square Station
* Cambridge, MA 02238
* ecognome@aol.com
* If you incorporate any of this software in any kind of
* commercial product, please send $2 per copy distributed
* to the above address.
*/
/*
* RTFText(rtf-text)
# returns the text from some RTF as a string, ignoring the styling.
*/
#include <HyperXCmd.h>
#include <stdlib.h>
#include <ctype.h>
#include "SetUpA4.h"
#include <string.h>
#include "lists.h"
#include "rtf.h"
Handle HStr(char *);
XCmdPtr xptr;
void error(char *);
int goterror;
pascal void
main(paramPtr)
XCmdPtr paramPtr;
{
Handle txt;
RememberA0();
SetUpA4();
xptr = paramPtr;
goterror = 0;
if(paramPtr->paramCount != 1){
error("error : usage RTFText(rtf-text)\rCopyright 1992 by Robert Morris.");
goto out;
}
parsertf(paramPtr->params[0], (MyStyleHandle *) 0, &txt);
if(goterror)
goto out;
paramPtr->returnValue = txt;
txt = 0;
out:
if(goterror && paramPtr->returnValue == 0)
paramPtr->returnValue = HStr("error : out of memory!");
RestoreA4();
}
Handle
HStr(str)
char *str;
{
Handle newHndl;
newHndl = (Handle) NewHandle((long) strlen(str) + 1);
if(newHndl == 0)
return(0);
strcpy((char *) (*newHndl), str);
return(newHndl);
}
void
error(s)
char *s;
{
if(goterror == 0)
xptr->returnValue = HStr(s);
goterror = 1;
}